#pragma once

#ifndef _CBASICPACKET_H_
#define _CBASICPACKET_H_

class CBasicPacket
{
protected:
	unsigned char	type;
	unsigned char	size;
	unsigned short	num;
	unsigned char   data[500];

	long long m_packetIdentifier;
	unsigned char m_dontProcessOnZone;

public:
	//(un)pack functions for Big Endian(BE) targets
	static void packBitsBE(unsigned char* target, unsigned long long value, int byteOffset, int bitOffset, unsigned char lengthInBit);
	static void packBitsBE(unsigned char* target, unsigned long long value, int bitOffset, unsigned char lengthInBit);
	static unsigned long long unpackBitsBE(unsigned char* target,int byteOffset, int bitOffset, unsigned char lengthInBit);
	static unsigned long long unpackBitsBE(unsigned char* target,int bitOffset, unsigned char lengthInBit);
	//(un)pack functions for Little Endian(LE) targets
	static void packBitsLE(unsigned char* target, unsigned long long value, int byteOffset, int bitOffset, unsigned char lengthInBit);
	static void packBitsLE(unsigned char* target, unsigned long long value, int bitOffset, unsigned char lengthInBit);
	static void packBitsLE(char* target, unsigned long long value, int bitOffset, unsigned char lengthInBit);
	static unsigned long long unpackBitsLE(char* target,int bitOffset, unsigned char lengthInBit);
	static unsigned long long unpackBitsLE(unsigned char* target,int bitOffset, unsigned char lengthInBit);
	static unsigned long long unpackBitsLE(unsigned char* target,int byteOffset, int bitOffset, unsigned char lengthInBit);

	CBasicPacket(void);
	~CBasicPacket(void);

	unsigned char getDontProcessOnZoneValue(void);
	long long getPacketIdentifier(void);

	unsigned char	CBasicPacket::getSize();
	unsigned char	CBasicPacket::getType();
	void			CBasicPacket::setNum(unsigned short num);
	void			CBasicPacket::write(unsigned char * buf);

};
#endif
